/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/



#if !defined(AFX_PGLHISTOGRAM_H__DF6454DC_6F1D_4618_B49E_7813F6098E96__INCLUDED_)
#define AFX_PGLHISTOGRAM_H__DF6454DC_6F1D_4618_B49E_7813F6098E96__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLLine1D.h>
#include <pgl/core/PGLData.h>

/*! \brief A 1-D histogram

  \ingroup PGLMiscChartGroup
*/
class PGLCORE_EXT_CLASS CPGLHistogram : public CPGLLine1D 
{
PGL_DECLARE_DYNCREATE(CPGLHistogram);
public:

	//! An histogram object
	typedef THistogram<float,float> Histogram;

	//! \name Constructors
	//@{
	//! Default constructor
	CPGLHistogram(const CPGLColor& _FrontColor = CPGLColor(), const CPGLColor& _FillColor = CPGLColor(1,1,1,1), LPCTSTR _eDashPattern = PGL_LINE_CONT );
	//! Copy contructor
	CPGLHistogram( const CPGLHistogram& h)	{ *this = h;};
	//! Assignment constructor
	CPGLHistogram& operator = (const CPGLHistogram& h);
	//! Destructor
	virtual ~CPGLHistogram();
	//@}

	//! \name Flags
	//@{
	//! Sets normalized histogram
	void SetNormalized( bool bNormalize = true)	{	m_bNormalized=bNormalize;};
	//! returns true if normalized
	bool IsNormalized() const					{	return m_bNormalized;};
	//@}

	//! \name Histogram object
	//@{
	//! return reference to histogram object, const
	const Histogram& GetHistogram() const	{	return m_histogram;};
	//! return reference to histogram object
	Histogram& GetHistogram()				{	return m_histogram;};
	//! Compute histogram
	void ComputeHistogram(bool bComputeMinMax = true);
	//@}

	//! \name Object dimension
	//@{
    /** Extent computation
     * 
     * \param gfx graphical interface
     * \param rExtent extent of object
     */
    virtual void GetUnionExtent(gfxinterface::CGfxInterface& gfx, CPGLRectD& rExtent);
    ///virtual function to override in derived classes
    virtual void UpdateExtent(gfxinterface::CGfxInterface& gfx);
	//@}

	//! \name Serialization and debugging
	//@{
	//! Serialization
	void SerializeXML(CPGLArchive& ar);
	#ifdef _DEBUG
		//! MFC Dump
	    virtual void Dump( CDumpContext& dc ) const;
		//! MFC AssertValid
	    virtual void AssertValid() const;   
	#endif
	//@}

	//! \name Values
	//@{
	virtual void SetValues( CPGLDataPtr pValues, bool bComputeMinMax = true );
	//@}
protected:
	virtual void PlotLineStripGfx(gfxinterface::CGfxInterface& gfx);

protected:
	//! \name Attributes
	//@{
	//! the histogram
	Histogram m_histogram;
	//! normalized or not histogram
	bool m_bNormalized;
	//@}
};

PGL_DECLARE_SMARTPTR( CPGLHistogram );

#endif // !defined(AFX_PGLHISTOGRAM_H__DF6454DC_6F1D_4618_B49E_7813F6098E96__INCLUDED_)
